<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="robots" content="NONE,NOARCHIVE" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><%= htmlWebpackPlugin.options.title || 'Sentry Dev'%></title>
    <script type="text/javascript">
    try {
      var reg = new RegExp(/\/organizations\/(.+?(?=(\/|$)))(\/|$)/, 'i');
      var organization = window.location.pathname;
      var slug = organization.match(reg)[1];
      var preloadPromises = { orgSlug: slug };

      function promiseRequest(url) {
        return new Promise(function (resolve, reject) {
          var xhr = new XMLHttpRequest();
          xhr.open('GET', url);
          xhr.onload = function () {
            try {
              this.status >= 200 && this.status < 300
                ? resolve([JSON.parse(xhr.response), this.statusText, xhr])
                : reject([this.status, this.statusText]);
            } catch(e) {
              reject();
            }
          };
          xhr.onerror = function () {
            reject([this.status, this.statusText]);
          };
          xhr.send();
        });
      }

      function makeUrl(suffix) {
        return '/api/0/organizations/' + slug + suffix;
      }

      window.__sentry_preload = preloadPromises;

      if (slug !== 'new') {
        preloadPromises.organization = promiseRequest(makeUrl('/?detailed=0'));
        preloadPromises.projects =  promiseRequest(makeUrl('/projects/?all_projects=1&collapse=latestDeploys'));
        preloadPromises.teams = promiseRequest(makeUrl('/teams/'));
      }
    } catch(_) {}
    </script>
  </head>

  <body>
    <% if (htmlWebpackPlugin.options.unsupportedBrowser) { %>
    <style>.unsupported-browser { display: none; }</style>
    <div class="unsupported-browser">
      Sorry, your browser is not supported.  Please upgrade to
      the latest version or switch your browser to use this site.
      See <a href="http://outdatedbrowser.com/">outdatedbrowser.com</a>
      for options.
    </div>
    <% } %>

    <div id="blk_router">
      <div class="loading triangle">
        <div class="loading-mask"></div>
        <div class="loading-indicator" data-test-id="loading-indicator">
          <img src="<%=require('sentry-images/sentry-loader.svg')%>" />
        </div>
        <div class="loading-message">
          <p>Please wait while we load an obnoxious amount of JavaScript.</p>
          <p>
            <small>You may need to disable adblocking extensions to load Sentry.</small>
          </p>
        </div>
      </div>
    </div>

    <% if (htmlWebpackPlugin.options.window) { %>
    <script>
      <% for (var varName in htmlWebpackPlugin.options.window) { %>
          window['<%=varName%>'] = <%= JSON.stringify(htmlWebpackPlugin.options.window[varName]) %>;
        <% } %>
    </script>
    <% } %>
  </body>
</html>
